package com.yunji.order.emuns;

import com.yunji.common.utils.bean.BeanUtils;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.order.emuns
 * @Title: WechatCode
 * @Description: 微信支付结果状态
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-04-12 10:21:50      V1.0        HuaAo       新建类
 */

public enum PayState {
    SUCCESS("SUCCESS", "支付成功"),
    FAILURE("REFUND", "转入退款"),
    NOTPAY("NOTPAY", "未支付"),
    CLOSED("CLOSED", "已关闭"),
    REVOKED("REVOKED", "已撤销(付款码支付)"),
    USERPAYING("USERPAYING", "用户支付中(付款码支付)"),
    PAYERROR("PAYERROR", "支付失败(其他原因，如银行返回失败)");

    private final String code;
    private final String text;

    PayState(String code, String text) {
        this.code = code;
        this.text = text;
    }

    public String getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    public static String get(String code) {
        if (BeanUtils.isNull(code)) {
            return null;
        }
        PayState[] enums = PayState.values();
        for (PayState e : enums) {
            if (e.code.equals(code)) {
                return e.text;
            }
        }
        return null;
    }
}
